{include file='ebcms@common/header' /}
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <h3>
                <span>栏目管理</span>
                <div class="btn-group btn-group-sm">
                    <button type="button" class="btn btn-danger dropdown-toggle" data-toggle="dropdown">
                    添加 <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu" role="menu">
                        <li><a href="{:url('add',['type'=>'channel'])}">栏目</a></li>
                        <li><a href="{:url('add',['type'=>'page'])}">单页</a></li>
                        <li><a href="{:url('add',['type'=>'jump'])}">跳转</a></li>
                    </ul>
                </div>
            </h3>
            <div class="table-responsive">
                <table class="table table-bordered table-hover table-ebcms">
                    <tbody>
                        <tr>
                            <th style="width: 80px;">ID</th>
                            <th style="width: 80px;">排序</th>
                            <th style="width: 130px;">操作</th>
                            <th style="width: 50px;">状态</th>
                            <th style="width: 50px;">导航</th>
                            <th>标题</th>
                            <th>名称(路径)</th>
                            <th>类型</th>
                            <th>模板</th>
                            <th>内容数</th>
                        </tr>
                        {php}
                            $rules = \app\content\model\Channel::with('extend') -> order('sort desc,id asc') -> select();
                            $rules = \ebcms\Tree::tree($rules);
                            $data = [];
                            \ebcms\Tree::leveltree($rules,$data);
                            //var_dump($data);die;
                        {/php}
                        {foreach name='data' item='vo'}
                            <tr>
                                <td>{$vo.id}</td>
                                <td>
                                    <input value="{$vo.sort}" class="form-control input-sm ebcms-change" url="{:url('resort')}" data-id="{$vo.id}">
                                </td>
                                <td>
                                    {if condition="check_auth('delete')"}
                                    <button type="button" class="btn btn-primary btn-sm ebcms-do" url="{:url('delete')}" data-ids='{$vo.id}' confirm="删除后不可恢复，确定删除？"><span class="glyphicon glyphicon-remove"></span></button>
                                    {/if}
                                    {if condition="check_auth('edit')"}
                                    <a href="{:url('edit?id='.$vo['id'])}" class="btn btn-primary btn-sm"><span class="glyphicon glyphicon-pencil"></span></a>
                                    {/if}
                                    <a href="{$vo.url}" target="_blank" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-share-alt"></span></a>
                                </td>
                                <td>
                                    {if condition="check_auth('status')"}
                                        {eq name='vo.status' value='1'}
                                        <button type="button" class="btn btn-primary btn-sm ebcms-do" url="{:url('status')}" data-ids='{$vo.id}' data-value='0'><span class="glyphicon glyphicon-ok-sign"></span></button>
                                        {else/}
                                        <button type="button" class="btn btn-warning btn-sm ebcms-do" url="{:url('status')}" data-ids='{$vo.id}' data-value='1'><span class="glyphicon glyphicon-ban-circle"></span></button>
                                        {/eq}
                                    {/if}
                                </td>
                                <td>
                                    {if condition="check_auth('nav')"}
                                        {eq name='vo.nav' value='1'}
                                        <button type="button" class="btn btn-primary btn-sm ebcms-do" url="{:url('nav')}" data-ids='{$vo.id}' data-value='0'><span class="glyphicon glyphicon-ok-sign"></span></button>
                                        {else/}
                                        <button type="button" class="btn btn-warning btn-sm ebcms-do" url="{:url('nav')}" data-ids='{$vo.id}' data-value='1'><span class="glyphicon glyphicon-ban-circle"></span></button>
                                        {/eq}
                                    {/if}
                                </td>
                                <td>
                                    <span>{$vo._level|str_repeat='&nbsp;&nbsp;&nbsp;',###}┣</span>
                                    <span><a href="{:url('edit',['id'=>$vo['id']])}">{$vo.title}</a></span>
                                </td>
                                <td>
                                    {in name='vo.type' value='channel,page'}
                                    <span>{$vo._level|str_repeat='&nbsp;&nbsp;&nbsp;',###}┣{$vo.name}</span>
                                    {/in}
                                </td>
                                <td>
                                    {switch name='vo.type'}
                                        {case value='channel'}
                                        {if condition="$vo['extend']['title'] !== null"}{$vo.extend.title}{/if}
                                        {/case}
                                        {case value='jump'}
                                        <span class="text-danger">跳转</span>
                                        {/case}
                                        {case value='page'}
                                        <span class="text-danger">单页</span>
                                        {/case}
                                        {default/}
                                    {/switch}
                                </td>
                                <td>
                                    {switch name='vo.type'}
                                        {case value='channel'}
                                            {$vo.tpl|default='channel'}.html - {$vo.tpl_detail|default='detail'}.html
                                        {/case}
                                        {case value='page'}
                                            {$vo.tpl|default='page'}.html
                                        {/case}
                                        {default/}
                                    {/switch}
                                </td>
                                <td>
                                    {switch name='vo.type'}
                                        {case value='channel'}
                                            {$vo.count}
                                        {/case}
                                        {default/}
                                    {/switch}
                                </td>
                            </tr>
                        {/foreach}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
{include file='ebcms@common/footer' /}